import * as THREE from "three"

// 初始化地面
export const initGround = () => {
  const ground = createGround();

  // TODO
  // 任何地面贴图渲染啥的在这

  return ground
}

const createGround = () => {
  // 水泥地
  // const geometry = new THREE.BoxGeometry(60, 60, 1);
  // // const geometry = new THREE.PlaneGeometry(10, 10)

  // const textureLoader = new THREE.TextureLoader(); // 纹理加载器
  // const texture = textureLoader.load(
  //   "/images/Cement.png",
  //   function (texture) {
  //     texture.wrapS = texture.wrapT = THREE.RepeatWrapping;
  //     texture.offset.set(0, 0);
  //     // texture.repeat.set(180, 180);
  //   }
  // );
  // const material = new THREE.MeshLambertMaterial({
  //   // color: 0x00ff00,
  //   map: texture,
  //   side: THREE.DoubleSide,
  //   transparent: true
  //   // metalness: 0.3,  // 金属质感
  //   // roughness: 0.8    // 表面粗糙度
  // })
  // const ground = new THREE.Mesh(geometry, material)
  // ground.receiveShadow = true

  // ground.rotation.x = -Math.PI / 2 // 使平面水平
  // ground.position.y = -Math.PI / 2

  // ground.position.x = 0;
  // ground.position.z = 0

  // 空白场地
  const ground = new THREE.Mesh(new THREE.PlaneGeometry(200, 200), new THREE.MeshPhongMaterial({ color: 0xcbcbcb, depthWrite: false }));
  ground.rotation.x = - Math.PI / 2;
  ground.receiveShadow = true;

  return ground

}
